package com.tgslc.defaultManagement.serviceDelegate;

import com.tgslc.defaultManagement.utils.Borrower;

import java.util.ArrayList;
import java.util.List;

public class BorrowerServiceDelegate {

  private List<Borrower> borrowerList;
  private Borrower borrower;

  public void setBorrowerList(List<Borrower> borrowerList) {
    this.borrowerList = borrowerList;
  }

  public List<Borrower> getBorrowerList() {
    return borrowerList;
  }

  public void setBorrower(Borrower borrower) {
    this.borrower = borrower;
  }

  public Borrower getBorrower() {
    return borrower;
  }

  public void fetchBorrowersList() {
    List<Borrower> list = new ArrayList<Borrower>();
    Borrower borrower = new Borrower();
    borrower.setBorrowerId(123L);
    borrower.setBorrowerName("TOM");
    borrower.setBorrowerSSN("123-456-7890");
    list.add(borrower);
    borrower = new Borrower();
    borrower.setBorrowerId(456L);
    borrower.setBorrowerName("HARRY");
    borrower.setBorrowerSSN("635-316-7890");
    list.add(borrower);
    this.borrowerList = list;    
  }

  public void fetchBorrower(Long borrowerId) {
    List<Borrower> list = this.getBorrowerList();
    for (int i = 0; i < list.size(); i++) {
      if (list.get(i).getBorrowerId().equals(borrowerId)) {
        this.borrower = list.get(i);
        break;
      }
    }
  }
}

